var LoginValidator = function() {  
    var handleSubmit = function() { 
        $('.form-horizontal').validate({  
            errorElement : 'span',  
            errorClass : 'help-block',  
            focusInvalid : false,  
            rules : {  
                loginid : {  
                    required : true  
                },  
                pwd : {  
                    required : true  
                }
            },  
            messages : {  
                loginid : {  
                    required : "请输入用户名."  
                },  
                pwd : {  
                    required : "请输入密码."  
                }
            },  
  
            highlight : function(element) {  
                $(element).closest('.control-group').addClass('error');  
            },  
  
            success : function(label) { 
                label.closest('.control-group').removeClass('error');  
                label.remove();
            },  
  
            errorPlacement : function(error, element) {  
            	element.parent('div').append(error);  
            },  
  
            submitHandler : function(form) {
                form.submit();
            }  
        });  
  
        $('.form-horizontal input').keypress(function(e) {  
            if (e.which == 13) {  
                if ($('.form-horizontal').validate().form()) {  
                    $('.form-horizontal').submit();  
                }  
                return false;  
            }  
        });  
    }  
    return {  
        init : function() {  
            handleSubmit(); 
        }  
    };  
  
}();  
function loginProc(){
	var loginid=$("#loginid").val();
	var pwd=$("#pwd").val();
	$('#myModal').modal('show');
	$.post("system/login.action",{"user.loginid":loginid,"user.pwd":pwd}, function(result) {
		if(result.msg=="succ"){
			$($('#myModal').children()[0]).text('正在加载主界面...');
			$.post("system/load_Permission.action",{"loginid":loginid},function(result){
				if(result.msg!=null && result.msg!=""){
					window.location.href=result.msg.substr(3);
				}else{
					alert("您目前没有任何操作权限，请联系管理员.");
				}
			});
		}else{
			$('#myModal').modal('hide');
			$("#infotext").html(result.msg);
			$('#myinfo').modal('show');
		}
	});
};

